<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta
      name="viewport"
      content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"
    />

    <title>纯CSS实现瀑布流布局</title>
    <link rel="stylesheet" href="index.css" />

    <link rel="icon" type="image/x-icon" href="../../../favicon.ico" />
</head>

  <body>
    <div class="container" id="app"></div>
  </body>
</html>

<script>
  document.addEventListener("DOMContentLoaded", function () {
    const container = document.getElementById("app");

    // 创建45个item元素 (原来3个v-for="item in 15")
    for (let j = 0; j < 3; j++) {
      for (let i = 1; i <= 15; i++) {
        const item = document.createElement("div");
        item.className = "item";

        const img = document.createElement("img");
        // 修改图片路径为相对路径
        img.src = "../../images/flex/" + i + ".jpg";
        img.alt = "";

        item.appendChild(img);
        container.appendChild(item);
      }
    }
  });
</script>
